//
//  AppMacro.h
//
//  Created by Evan Xie on 8/3/15.
//  Copyright (c) 2015 Family Wings. All rights reserved.
//

#ifndef AppMacro_h
#define AppMacro_h

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


/** Time Constants */
#define AMTimeIntervalSecond    1
#define AMTimeIntervalMinute    60
#define AMTimeIntervalHour      3600
#define AMTimeIntervalDay       86400
#define AMTimeIntervalWeek      604800


/** Quick access for app information */
#define AMAppBuild              [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey] // 100
#define AMAppShortVersion       [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"] // 1.0
#define AMAppVersion            [AMAppShortVersion stringByAppendingFormat:@" (%@)", AMAppBuild] // 1.0 (100)


/** Quick access for UIDevice information */
#define AMDeviceModel           [[UIDevice currentDevice] model]
#define AMDeviceName            [[UIDevice currentDevice] name]
#define AMDeviceOSVersion       [[UIDevice currentDevice] systemVersion]


/** Quick access for device status */
#define AMStatusBarOrientation  [UIApplication sharedApplication] statusBarOrientation]


/** Quick access for the sandbox of app. */
#define AMDirectoryApplicationSupport  NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES)[0]
#define AMDirectoryCaches              NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0]
#define AMDirectoryDocuments           NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]
#define AMDirectoryLibrary             NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0]
#define AMDirectoryTemp                NSTemporaryDirectory()


/** Quick access for app singleton instance objects. */
#define AMApplication           [UIApplication sharedApplication]
#define AMFileManager           [NSFileManager defaultManager]
#define AMNotificationCenter    [NSNotificationCenter defaultCenter]
#define AMUserDefaults          [NSUserDefaults standardUserDefaults]


/** Quick access for some common methods */
#define AMRespondsSelector(target, sel)    [target respondsToSelector:@selector(sel)]


/** Quick access for generating UIColor object. */
#define AMUIColorFromRGB(r, g, b)        [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
#define AMUIColorFromRGBA(r, g, b, a)    [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]

#define kSectionNameKey @"SectionNameKey"
#define kItemNamesKey   @"kItemNamesKey"

#endif
